package com.tong.cloud.feign.processor;

import com.tong.cloud.feign.annotation.BasicAuth;
import feign.MethodMetadata;
import feign.auth.BasicAuthRequestInterceptor;

import java.lang.annotation.Annotation;

public class BasicAuthClassProcessor implements AnnotatedClassProcessor {
    @Override
    public Class<? extends Annotation> getAnnotationType() {
        return BasicAuth.class;
    }

    @Override
    public void process(MethodMetadata data, Class<?> clz) {
        BasicAuth auth= clz.getAnnotation(BasicAuth.class);
        new BasicAuthRequestInterceptor(auth.userName(), auth.password()).apply(data.template());
    }
}
